package com.helmlabs.grouper.webapp.controllers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.lucene.document.Document;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.helmlabs.grouper.search.service.SearchService;
import com.helmlabs.grouper.search.service.SearchServiceFactory;

@Controller
@RequestMapping({"/search/search.html"})
public class SearchController {

	private final SearchService searchService = SearchServiceFactory.getSearchService();
	
	@SuppressWarnings("unchecked")
	@RequestMapping(method=RequestMethod.GET, value="/search/search.html")
	public ModelAndView search(@RequestParam("q") String query){
		ModelAndView model = new ModelAndView("search/results");
		List results = searchService.search(query);
		model.addObject("results", results);
		return model;
	}
	
	

}
